package com.city.repository.report;

import com.city.domain.auth.format.CtBranchFormat;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface CtBranchFormatRepository extends JpaRepository<CtBranchFormat,Integer> {


    @Query(value = "select c1.id id, c1.name name , c2.name parent,c1.type type " +
            "from ct_branch as c1 left join ct_branch as c2 on c2.id=c1.parent " +
            "limit ?1,?2",nativeQuery = true)
    List<CtBranchFormat> findByFormatLimit(Integer page, Integer limit);

    @Query(value = "select c1.id id, c1.name name , c2.name parent,c1.type type " +
            "from ct_branch as c1 left join ct_branch as c2 on c2.id=c1.parent " +
            "WHERE c1.id=?1",nativeQuery = true)
    CtBranchFormat findById(int id);
}
